package com.cskaoyan.javase.oop2._1extends._10override._0introduction;

/**
 * 测试方法的覆盖
 *
 * @since 16:47
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo2 {
    public static void main(String[] args) {
        Animal a = new Person();
        a.work();
        a.invokeWork();

        // 匿名对象默认引用就是对象的类型
        new Person().work();
        new Person().haveFrench();
        new Animal().work();
        new Animal().invokeWork();
    }
}

class Animal {
    public void work() {
        System.out.println("每天晒太阳,不用上学,不用工作,快活的活十年~");
    }

    public void invokeWork() {
        work();
    }
}

class Person extends Animal {
    public void work() {
        System.out.println("快乐做一只做牛马~~");
    }

    public void haveFrench() {
        System.out.println("搞点🍟来~");
    }
}